
<div id="div_liste_devis" class="row-fluid">
    <script>
    devis_id = -1
        </script>
    <div class="span12">
        <div class="box gradient">
            <div class="title" style="text-align: center">
                <h4>Liste Devis</h4>
            </div>
            <div id="div-list-user" class="content noPad clearfix">
                <div id="DataTables_Table_0_wrapper" class="dataTables_wrapper" role="grid">
                    <div id="DataTables_Table_0_filter" class="dataTables_filter">
                        <div class="span12">

                            <div class="span2">
                                <label>
                                    N° Devis:
                                    <input class="text" type="text" id="filtre_numero" style="width:80%;margin-left: 0"/>
                                </label>
                            </div>
                            <div class="span2">
                                <label>
                                    Date:
                                    <input class="text" type="text" id="filtre_date1" style="width:80%;margin-left: 0"/>
                                </label>
                            </div>
                            <div class="span2">
                                <label>
                                    Jusqu'à:
                                    <input class="text" type="text" id="filtre_date2" style="width:80%;margin-left: 0" />
                                </label>
                            </div>
                            <div class="span2">
                                <label>
                                    Heure:
                                    <select id="filtre_heure" class="nostyle"  style="width:80%;margin-left: 0"required="required">
                                        <option value="1"></option>
                                        <option value="2">07h -> 12h</option>
                                        <option value="3">12h -> 21h</option>
                                        <option value="4">08h -> 10h</option>
                                        <option value="5">10h -> 12h</option>
                                        <option value="6">12h -> 14h</option>
                                        <option value="7">14h -> 16h</option>
                                        <option value="8">16h -> 18h</option>
                                        <option value="9">18h -> 20h</option>
                                        <option value="10">20h -> 22h</option>
                                    </select>
                                </label>
                            </div>

                            <div class="span2">
                                <label>
                                    TTC entre:
                                    <input class="text" type="text" id="filtre_ttc1" style="width:80%;margin-left: 0"/>
                                </label>
                            </div>
                            <div class="span2">
                                <label>
                                    ET:
                                    <input class="text" type="text" id="filtre_ttc2" style="width:80%;margin-left: 0"/>
                                </label>
                            </div>
                            </tr>
                            </table>


                        </div>


                        <div id="liste_devis">

                {% include 'GdsVenteBundle:PointVente:page_liste_devis.html.twig' %}
                        </div>
                            <div class="span12" style="margin: 0">
                            <div class="form-actions" style="margin: 0">
                                <button class="btn btn-info" type="button" onclick="chargerDevis()">Charger Devis</button>
                                <button class="btn" type="button" onclick="$('#cboxClose').click()">Annuler</button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div><!-- End .box -->

    </div><!-- End .span12 -->
</div>
    <script>
                                    $(document).ready(function() {
                                        heure1 = ''
                                        heure2 = ''
                                        date1 = ''
                                        date2 = ''
                                        $("#filtre_date2").val(currentDate)
                                        $("#filtre_date1").val('')
                                        $('#filtre_heure').val(1)
                                        $('#filtre_numero').val('')
                                        $('#filtre_raison_social').val('')
                                        $('#filtre_reference').val('')
                                        $('#filtre_designation').val('')
                                        $('#filtre_ttc1').val('')
                                        $('#filtre_ttc2').val('')
                                        $('#filtre_type').val(2)
                                        date2 = changeFormatDate($('#filtre_date2').val())
                                    })
                                    $("#filtre_date1").datepicker({
                                        changeMonth: true,
                                        onClose: function(selectedDate) {
                                            $("#filtre_date2").datepicker("option", "minDate", selectedDate);
                                        }
                                    });
                                    $("#filtre_date2").datepicker({
                                        defaultDate: "+1w",
                                        changeMonth: true,
                                        onClose: function(selectedDate) {
                                            $("#filtre_date1").datepicker("option", "maxDate", selectedDate);
                                        }
                                    });
                                    $('#filtre_heure').change(function() {
                                        heure = $("#filtre_heure option:selected").text();
                                        heure = heure.split('h')
                                        heure1 = heure[0] * 3600
                                        if (heure1 != 0) {
                                            heure2 = heure[1]
                                            heure2 = heure2.split('->')
                                            heure2 = heure2[1] * 3600
                                        } else {
                                            heure1 = ''
                                            heure2 = ''
                                        }
                                        goToPage('{{path(pagination.route)}}?type=ajax')
                                    })
                                    $('#filtre_numero').keyup(function() {
                                        var val = $(this).val();
                                        if (val.length > 0)
                                            goToPage('{{path(pagination.route)}}?type=ajax')
                                    })

                                    $('#filtre_date1').change(function() {
                                        date1 = changeFormatDate($('#filtre_date1').val())
                                        goToPage('{{path(pagination.route)}}?type=ajax')
                                    })
                                    $('#filtre_date2').change(function() {
                                        date2 = changeFormatDate($('#filtre_date2').val())
                                        goToPage('{{path(pagination.route)}}?type=ajax')
                                    })
                                    $('#filtre_ttc1').keyup(function() {
                                        goToPage('{{path(pagination.route)}}?type=ajax')
                                    })
                                    $('#filtre_ttc2').keyup(function() {
                                        goToPage('{{path(pagination.route)}}?type=ajax')
                                    })
                                    $('#filtre_type').change(function() {
                                        goToPage('{{path(pagination.route)}}?type=ajax')
                                    })
                                    function goToPage(url) {
                                        $.ajax({
                                            url: url,
                                            data: '&type=ajax&numero=' + $('#filtre_numero').val() + '&client_id=' + client_id
                                                    + '&date1=' + date1 + '&date2=' + date2
                                                    + '&heure1=' + heure1 + '&heure2=' + heure2
                                                    + '&ttc1=' + $('#filtre_ttc1').val() + '&ttc2=' + $('#filtre_ttc2').val(),
                                            success: function(data) {
                                                $('#liste_devis').html(data)
                                            }
                                        })
                                    }
                                    function changeFormatDate(date) {
                                        if (date == '')
                                            return date
                                        date = date.split('/')
                                        date = date[2] + '-' + date[1] + '-' + date[0]
                                        return date
                                    }
        </script>

